package com.pureut.production.controller;


import com.pureut.common.core.web.controller.BaseController;
import com.pureut.common.core.web.domain.AjaxResult;
import com.pureut.common.core.web.page.TableDataInfo;
import com.pureut.common.log.annotation.Log;
import com.pureut.common.log.enums.BusinessType;
import com.pureut.common.security.annotation.RequiresPermissions;
import com.pureut.production.domain.dto.ProcessTempleteDto;
import com.pureut.production.domain.vo.ProcessTempleteVo;
import com.pureut.production.domain.vo.PublicProcessVo;
import com.pureut.production.service.ProcessCardTempleteService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 工艺卡模板控制层
 * @author: CM
 * @date: 2023/2/16  16:37
 */
@RestController
@RequestMapping("/processTemplete")
public class ProcessCardTempleteController extends BaseController {

    /**
     * 工艺卡模板Service
     */
    @Resource
    ProcessCardTempleteService processCardTempleteService;

    /**
     * 新增工艺卡模板
     */
    @RequiresPermissions("productionTube:processmage:processtemplate:add")
    @Log(title = "新增工艺卡模板", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@Validated @RequestBody PublicProcessVo publicProcessVo){
        return toAjax(processCardTempleteService.add(publicProcessVo));
    }

    /**
     * 查询工艺卡模板列表
     */
    @RequiresPermissions("productionTube:processmage:processtemplate:list")
    @GetMapping("/list")
    public TableDataInfo list(ProcessTempleteVo processTempleteVo)
    {
        startPage();
        List<ProcessTempleteDto> list = processCardTempleteService.selectTempleteList(processTempleteVo);
        return getDataTable(list);
    }

    /**
     * 查看工艺卡模板
     */
    @RequiresPermissions("productionTube:processmage:processtemplate:query")
    @GetMapping("/view/{id}")
    public AjaxResult view(@PathVariable("id") Long id) {
        return AjaxResult.success(processCardTempleteService.getView(id));
    }

    /**
     * 根据线别查看工艺卡模板
     */
    @GetMapping("/getLine")
    public AjaxResult getLine(String line) {
        return AjaxResult.success(processCardTempleteService.getLine(line));
    }

    /**
     * 工艺卡模板删除
     */
    @RequiresPermissions("productionTube:processmage:processtemplate:remove")
    @Log(title = "工艺卡模板删除", businessType = BusinessType.DELETE)
    @DeleteMapping("/delete/{ids}")
    public AjaxResult remove(@PathVariable("ids") String ids) {
        return toAjax(processCardTempleteService.remove(ids));
    }

    /**
     * 工艺卡模板修改
     */
    @RequiresPermissions("productionTube:processmage:processtemplate:edit")
    @Log(title = "工艺卡模板修改", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult edit(@Validated @RequestBody PublicProcessVo publicProcessVo) {
        return toAjax(processCardTempleteService.edit(publicProcessVo));
    }



}
